package gdma.hqdes.calc;

import org.springframework.beans.factory.annotation.Qualifier;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author wangyue
 * @Version 3.0
 * @Date 2024-07-14
 */
@Qualifier("地市级指标D41计算类")
public class SC_S2_D41 implements ScoreCalculator {

    @Override
    public float doCalc(Map<String, String> inputArgs) {
        List<Float> justValues = inputArgs.entrySet().stream()
                .filter(e -> e.getKey().endsWith("1"))
                .map(e -> Float.parseFloat(e.getValue()))
                .collect(Collectors.toList());
        float sum = 0;
        for(float value : justValues) {
            if((int)value == 0) return 0;
            if((int)value == 50) return 50;
            sum += value;
        }
        return sum / justValues.size();
    }

}
